(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.currency.viewController', viewController);
	viewController.$inject = [ '$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'currencyService' ];
	function viewController($scope, Constants, layoutConfig, validatorConfig, gridService, authService, currencyService) {
		var ctrl = this, currencyInfo = $scope.$stateParams.params;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.currency = {};
		ctrl.init = function() {			
			var params = {
				ccy : currencyInfo.ccy
			};			
			return authService.view(params).then(function(response) {
				ctrl.currency = response.data || currencyInfo;
				currencyService.getCountryOptions().then(function(response) {
					ctrl.countryCodeOptions = response;
				}, function(error) {
					log.debug('can\'t load country code options' + angular.toJson(error));
				});			
				currencyService.getIntCalcBasisOptions().then(function(response) {
					ctrl.calbaseOptions = response;
				}, function(error) {
					log.debug('can\'t load interest calc options' + angular.toJson(error));
				});	
				ctrl.decimalNumOption = getDecimalNumOption();
			}, angular.noop);
			
		};
		
		function getDecimalNumOption() {
			var option = {
					"data" : [
					 {
						"value" : 1,
						"label" : 1
					}, {
						"value" : 2,
						"label" : 2
					}, {
						"value" : 3,
						"label" : 3
					} ]
			};
			return option;
		};
	}
})(angular);